﻿#pragma once

#include "BaseGlobal.h"
#include <QObject>
#include <QAbstractItemView>
//==================================================================================================
class BASE_EXPORT QItemViewTools : public QObject
{
	Q_OBJECT

public:
	QItemViewTools(QAbstractItemView * itemView, QWidget * toolsWidget, int col);

signals:
	void prepareShow( const QModelIndex & index );
	void showComplete( const QModelIndex & index );

public:
	const QModelIndex & currentIndex( ) const;

	void showTools( const QModelIndex & index );
	void hideTools( );

	void resize( );

protected:
	QModelIndex currentModelIndex;
	QAbstractItemView * itemView;
	QWidget * toolsWidget;
	int iColumn;
};

//==================================================================================================
class BASE_EXPORT QItemViewHoverTools : public QItemViewTools
{
	Q_OBJECT

public:
	QItemViewHoverTools(QAbstractItemView * itemView, QWidget * toolsWidget, int col);

protected:
	bool eventFilter( QObject * obj , QEvent * );
	bool hoverMove( QHoverEvent * hoverEvent );
};

//==================================================================================================
class BASE_EXPORT QItemViewSelectTools : public QItemViewTools
{
	Q_OBJECT

public:
	QItemViewSelectTools(QAbstractItemView * itemView, QWidget * toolsWidget,int col);

protected slots:
	void currentChanged( const QModelIndex & current, const QModelIndex & previous );
};

//==================================================================================================
inline const QModelIndex & QItemViewTools::currentIndex( ) const { return this->currentModelIndex; }
